package com.example.tests;

import java.util.Collections;
import java.util.List;

import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;

public class GroupCreationTests extends TestBase  {
	

	@Test(dataProvider = "randomValidGroupGenerator")
	  public void testGroupCreationWithValidData(GroupData group) throws Exception {
		app.getNavigationHelper().openMainPage();
		app.getNavigationHelper().openGroupPage();
		
		List<GroupData> oldList = app.getGroupHelper().getGroups();
		
 	    app.getGroupHelper().addNewGroup();
		app.getGroupHelper().fillGroupForm(group);
	    app.getGroupHelper().submitCreation();
	    app.getGroupHelper().returnToGroupPage();
	    
	    List<GroupData> newList = app.getGroupHelper().getGroups();
	    
	    oldList.add(group);
	    Collections.sort(oldList);
	    assertEquals(newList, oldList);
	  }

}
